<template>
  <FormItemWraaper v-bind="$attrs" :selectedWidget="selectedWidget" :editorProps="editorProps">
    <SwitchEditor
      v-if="['switch'].indexOf(selectedWidget?.type) != -1"
      :formItemFlag="false"
      v-model:value="state"
      :designer="designer"
      :editorProps="editorProps"
    />
    <Input v-else v-model:value="state" :placeholder="editorProps.placeholder || '请输入'" />
  </FormItemWraaper>
</template>
<script lang="ts" name="default-value-editor" setup>
  import { ref, watch, onMounted } from "vue"
  import { useRuleFormItem } from "/@/hooks/component/useFormItem"
  import { useI18n } from "/@/hooks/web/useI18n"
  import FormItemWraaper from "./PropFormItemWrapper.vue"
  import { Input } from "ant-design-vue"
  import SwitchEditor from "./SwitchEditor.vue"
  import type { Designer } from "../../type"
  const { t } = useI18n("diyForm")

  const props = defineProps({
    value: { type: [String, Number, Boolean, Object] },
    editorProps: { type: Object, default: () => {} },
    selectedWidget: Object,
    designer: { type: Object as () => Designer },
  })

  const emit = defineEmits(["update:value"])
  const [state] = useRuleFormItem(props, "value", "update:value")
  watch(
    () => state.value,
    (val: any) => {},
    {
      immediate: true,
    }
  )
  onMounted(() => {})
</script>

<style lang="less"></style>
